// 按需导入extend函数
import { extend, localize } from 'vee-validate'

// 导入需要的语言包
import zhCN from 'vee-validate/dist/locale/zh_CN.json'

// 导入全部规则
import * as rules from 'vee-validate/dist/rules'
// 注册语言包
localize({ zhCN })
// 激活当前语言
localize('zhCN')

Object.keys(rules).forEach(rule => {
    extend(rule, rules[rule])
})

// 添加自定义规则
extend('phone', {
    validate: value => {
        const reg = /^1[135789]\d{9}$/
        return reg.test(value)
    },
    message: '{_field_}格式不正确'
})